// pages/add/typesel/typesel.js
Page({
  data: {
    typeList: [{
        id: 1,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_mood@2x.png",
        text: "心情动态",
        isHot: false
      },
      {
        id: 2,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_sell@2x.png",
        text: "自家售卖",
        isHot: false
      },
      {
        id: 3,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_spread@2x.png",
        text: "派单推广",
        isHot: true
      },
      {
        id: 4,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_rentout@2x.png",
        text: "出租招租",
        isHot: false
      },
      {
        id: 5,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_used@2x.png",
        text: "二手商品",
        isHot: false
      },
      {
        id: 6,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_travel@2x.png",
        text: "旅游代买",
        isHot: false
      },
      {
        id: 7,
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_skills@2x.png",
        text: "发布技能",
        isHot: false
      }
    ]
  },
  onLoad: function (options) {},
  onShow: function () {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 1
      });
    }
  },
  select(e) {
    if (e.currentTarget.dataset.typeid == 3) {
      if (!wx.getStorageSync("firstOpenDispatch")) {
        getApp().globalData.vant.dialog.confirm({
          title: "温馨提示",
          message: "严禁发布任何违反国家法律法规的信息，一经发现，永久封号!",
          zIndex: "10000",
          confirmButtonText: "好的",
          closeOnClickOverlay: true,
          showCancelButton: false,
          className: "dialog-red",
        }).then(() => {
          wx.setStorageSync("firstOpenDispatch", 1);
          this.getUserInfo();
        });
      } else {
        this.getUserInfo();
      }
    }

    switch (e.currentTarget.dataset.typeid) {
      case 1:
        this.navTo("/pages/add/mood/mood");
        break;
      case 2:
        this.navTo("/pages/add/sell/sell");
        break;
      case 4:
        this.navTo("/pages/add/rent/rent");
        break;
      case 5:
        this.navTo("/pages/add/oldgood/oldgood");
        break;
      case 6:
        this.navTo("/pages/add/travelbuy/travelbuy");
        break;
      case 7:
        this.navTo("/pages/add/skills/skills");
        break;
    }
  },
  getUserInfo() {
    getApp().globalData.http.userInfo().then(res => {
      if (res.data.communityAuth == 0) {
        getApp().globalData.vant.dialog.confirm({
          title: "温馨提示",
          message: "请先进行实名认证!",
          zIndex: "10000",
          confirmButtonText: "去认证",
          closeOnClickOverlay: true,
          showCancelButton: false,
          className: "dialog-red",
        }).then(() => {
          wx.navigateTo({
            url: "/pages/my/districtapprove/districtapprove",
          });
        });
      } else {
        wx.navigateTo({
          url: "/pages/add/dispatch/dispatch",
        });
      }
    });
  },
  navTo(path) {
    wx.navigateTo({
      url: path,
    });
  }
})